home *** CD-ROM | disk | FTP | other *** search
- 0660103030566
- 1Sheet.DocBy Chor-ming Lung16-Feb, 1988
- 2page #
- 9[....................................................]
- êPreface:Ç
- Ihaveusedspreadsheetforquiteawhile,andIfeltit
- isafantastictool.MymostfamiliarspreadsheetisLotus
- 123(orVIPprofessional).OnethingthatIfeelterribleis
- itsMACROlanguage.Itisnotasuser-friendlyasits
- display.IfeelBASICismoresuitablethanMACROfora
- spreadsheetlanguage.
-
- So,IthinkthatmaybeprofitabletowriteaBASIC
- interpreterinaspreadsheetenvironment.ThefirstthingI
- havetodoiscreatingthespreadsheetprogram.
-
- IhadwrittenacalculatorprogramusingPersonal
- Pascal.Hence,Icanborrowalotoffunctionsfromthat
- program.AfterIfinishedthebook"ATARISTAPPLICATION
- PROGRAMMING"byPOLLACKandWEBERfromBANTAM,Ifelt
- ifIwantedtotakefulluseofGEM,IhavetoswitchtoC
- language.
-
- Tospeeduptheprocessofwritingthespreadsheet,I
- wasthinkingtodownloadsomepublicdomainspreadsheet
- programsandlearnedfromthemfirst.ThefirstoneItried
- isaMODULA-2programwrittenforBYTEmagazine.Tomy
- surprise,Icouldnotunderstandthesourcefile.Iknew
- thereisanotherpublicdomainspreadsheetprogram--
- MICROCAL(fromBorlandforTurboPascal).Thisprogramis
- mucheasiertounderstand.Ilearnedwhatisessentialfor
- buildingaspreadsheetprogramfromit.
-
- WithMICROCAL,BANTAMbook,andmycalculatorprogram,I
- thinkIcanmakearobustspreadsheetveryfast.After3and
- halfmonthsstruggle,Ihaveausablespreadsheetrunning
- now.
-
- ThespreadsheetisnotdoneyetandtheBASIC
- interpreterisstillalongwaytogo.Anyway,Ifeelthe
- spreadsheetisquiteusableeveninitsinfantstage.
-
-
- êDisclaimerÇ:
- Ihavemadeeveryefforttoinsuretheaccuracyofthe
- program.However,thereisnowarrantyeitherexpressor
- impliedforitsuses.
-
-
- êProgramspecificationÇ:
- SHEET(thenameofthisprogram)iswritteninMark
- WilliamsC.Theaccuracyforrealnumber(double)inMark
- WilliamsCisupto17digits(Lotus123isupto15digits).
- Therangeofcalculationis-1E-37to1E+37.Each
- spreadsheetcontains255by1280cellsandthespreadsheetis
- implementedbyusingSparseMatrix.(äWhatdoesSparceMatrix
- mean?Simplyspeaking,theemptycellswillnotoccupyany
- computermemory.So,youcaninsertsomethingincell
- "IU1280"withoutrunninginto"NOTENOUGHMEMORY"errorÇ).But
- therearesomepeculiareffectsthatisduetoSparseMatrix.
- Iwillrefertothislater.Anyinputtoacellwillbe
- tokenizedbeforeitisbeinginserted.Currently,onlyone
- windowcanbeused.Thefutureversionwillsupportupto4
- windows.
-
- ê
- RequirementsÇ:
- *Atari520STor1040STwithdiskdrive(s).
- *Monochromeorcolormonitor.
- *BothSHEET.PRGandCALC.RSConthesamedirectory.
- ê
-
- HowtolocateacellÇ:
- IassumeyouknowhowtooperatewithGEM.
-
- Tolocateacell,
- -useverticalandhorizontalsliderbarsto
- movetothedesireddisplayrange.
- -putthemouseoverthedesiredcellandpress
- leftbutton.
-
-
- êCellinputÇ:
- TheoperationofcellinputissimilartoLotus123.
- Anythingyoutypewillbeinsertedintotheeditingbuffer.
- äSpecialkey:Ç
- <Backspace>erasesthelastcharacter.
- <Return>terminatesinputandthecellcursor
- remainsonthesamecell.
- <UParrow>terminatesinputandthecellcursor
- moves
- onerowupifpossible.
- <Downarrow>terminatesinputandthecellcursor
- movesonerowdownifpossible.
- <Leftarrow>terminatesinputandthecellcursor
- movesonecolumnleftifpossible.
- <Rightarrow>terminatesinputandthecellcursor
- movesonecolumnrightifpossible.
- <Shift-arrows>terminatesinputandmovesthecell
- cursorinthedirectionyouspecifiedby
- page.
- äSpecialoperations:Ç
- <MOUSE>ifthemousecursorisinsidethedisplay
- rangeandifyoupresstheleftbutton,
- thecellcoordinatethatthemouseis
- overwillbeinsertedintotheediting
- buffer.(Sometimes,GEMdetectsthemouse
- eventveryfast.Butsometimesitdoes
- not.So,ifyouseenothingonthe
- editinglinewhenyoupressthemouse
- leftbutton,pressitalittlebit
- longer.Theproblemmaybecausedbytoo
- manyhide_mouse,show_mousecalls.Ifyou
- rebootthesystem,itwillalwaysdetect
- themouseeventveryfast.)
- <Sliders>Youcanchangethedisplayrangeby
- movingtheverticalorhorizontalslider
- bars.Butexcept<Backspace>,anyspecial
- keywillresumethedisplaybacktothe
- displayrangebeforeediting.
-
- êCelleditingÇ:
- Press<F2>andthecurrentcell'scontentwillbe
- insertedintotheeditingbuffer.êTheeditingsessionmustbe
- Çêterminatedby<ReturnÇ>.
- äSpecialkey:Ç
- <Leftarrow>moveonecharacterleftifpossible
- <Rightarrow>moveonecharacterrightifpossible
- <Shift-leftarrow>movetheeditingcursortotheleftmost
- character
- <Shift-rightarrow>movetheeditingcursortotherightmost
- character
- <Insert>toggletheINSERTmode.
- <Backspace>Deletethecharacterontheleftsideof
- editingcursor.
- <Delete>Deletethecharacterontherightsideof
- editingcursor.
-
-
- êtypeofinputÇ:
- (äInputarecase-insensitiveÇ)
- üFORMULA:ÇInputstringstartswith"+","-",digits,"("
- üSTATEMENT:ÇStringstartswith"!"
- üCOMMAND:ÇStringstartswith"@"
- üTEXT:ÇStringstartswith"\""orcharacterother
- thanaboveleadingcharacter.
- äDifferencesbetweentypes:Ç
- Internally,üFORMULAÇwillbeseparatedtoüFORMULAÇor
- üCONSTANTÇdependingwhethertheformulareferstoother
- cellsorothervariables(Yes,youcanusevariables.
- Remember,wewillhaveaBASICinterpreter).Acell
- containsüCONSTANTÇwillneverberecalculated.Itshould
- speedupthespreadsheetrecalculationtime.
- ü STATEMENTÇistokenizedBASICstatements.Youcan
- havemultiplestatementswith":"asseparator.(äRight
- now,everyinputSTATEMENTwillbeexecutedbefore
- insertingintothecurrentcell.Itshouldnotbeso.
- Therearetworeasonsforthat.First,Iwanttotest
- eachstatement.Second,IdonothavetheRUNstatement
- yetÇ.)Currently,therearejustafewstatementsbeing
- implemented:
- üSAVEÇ:Thesameaschoosingmenuitem"Save"
- üLOADÇ:Thesameaschoosingmenuitem"Load"
- ü=(Assigment)Ç:
- äcomparethefollowings:Ç
- +c1=12Itisalogicaloperation.A
- onemeansTRUEandzeromeans
- FALSE.
- !c1=12Itisastatementthatchanges
- thecontentofcell"C1"toa
- constantvalue12.
- üIFÇ:IFäconditionÇTHENästatementsÇ(ELSE
- ästatements)ÇTheELSEstatementis
- optional.
- üDEFINEÇ:Forusewithuserdefinefunctions.(äIn
- thefuture,alltheuserdefined
- functionswillbeonafilecall
- FORMULA.DEF.Youhavetodefineyour
- functionsbeforecallingSHEET.Ç)
- äe.g.Ç!definef(x,y)=3*x+4*y
- Inanycell,type+f(3,4),youwill
- have25asaresult.
- üNOTEÇ:-DonotuseüDEFINEÇasCOMMAND.
- -Inthecellthefunctionf(x,y)
- beingdefined,youwillsee:
- DEFINEF(X,Y)=3*PARAM1+4*PARAM2
- üYouhavetomanuallychange
- PARAMxÇwhenyouwanttochange
- itsdefinitionbyusing<F2>.
- -Eachfunctioncanhaveatmost
- 9andatleastoneparameters.
- -Youhavetodefinethe
- functionsagaineachtimeyou
- loadthespreadsheetin.
- üCOMMANDÇissimilartoüSTATEMENTÇ.Theonlyexception
- isitscontentwillnotbestoredinthecurrentcell.
- Forsavingsomememory,eachtimeyoudefineafunction,
- thepointerofitstokensisbeingpushedintothe
- symboltableinsteadofstoringthesametokenstwice.
- So,ifyousay"@DEFINEF(X,Y)=3*x+4*y".Afterits
- execution,thesymboltablehasapointerthatwillbe
- freedbacktotheoperatingsystem.Whatwillhappen?I
- donotknow!
-
-
- êChangedisplayformatÇ:
- äDefaultformat:Ç
- üTEXT:Çleftjustified
- üSTATEMENT:Çleftjustified
- üFORMULAÇ,
- üCONSTANT:Çthenumberofdigitsafterthedecimal
- pointissix;rightjustifiedof
- calculatedresult,ifpossible,ablank
- spaceisaddedattherightmostplace.
- üWIDTH:Ç9characterspercolumn
- êOnlycalculatedresultandcolumnwidthcanbechanged.Ç
- üChangecolumnwidth:Ç
- -Selectmenuitem"Width"frommenutitle"Sheet"
- -Changethecolumncoordinateandcolumnwidthas
- desired.
- üChangecellformatÇ:
- -Selectmenuitem"Reformat"frommenutitle"Sheet"
- -Choosetheformat,decimalplaceandrangeofcells
- youwanttochange.
- -êNOTEÇ:YOUCANONLYREFORMATTHOSECELLSWHICH
- EXIST.ThatisbecauseofSparseMatrix.Aftera
- cellhasbeencreated,thecellpossesses
- attributes.Ifyouformatsomeemptycellsand
- insertsomethingintothosecellsafterthat,those
- cellsappearasdefault.Itisnotabug.
-
-
- êCalculationÇ:
- üAccuracyÇ:upto17digits
- üRangeÇ:-1E-37to1E+37
- üArithmeticoperatorsÇ:
- "+","-","*","/","^",MOD
- üLogicaloperators:Ç
- AND,OR,NOT,"=","<>",">","<",">=","<=",
- "=>","=<"
- üBuilt-InfunctionsÇ:
- äMathÇ:SIN,COS,TAN,ASIN,ACOS,ATAN,LOG
- (älogarithmbase10Ç),EXP,LN(älogarithmbaseÇ
- äeÇ),ABS,INT(äintegerpartofarealnumberÇ),
- FRAC(äfractionpartofarealnumberÇ),SQR,
- SQRT,DATE(äcalculatetheJuliandays,3Ç
- äparameters,dd,mm,yyÇ),FACT(äfactorialÇ),
- RAD_DEG(äradiantodegreeÇ),DEG_RAD(ädegreetoÇ
- äradianÇ).
- äStatisticsÇ:
- AVERAGE,MEDIAN,STD(ästandarddeviationÇ)
- äMiscellaneousÇ:
- MAX,MIN,SUM
- ä FinanceÇ:
- NONE.
- äStringÇ:
- NONE.
- üPriorityÇ:
- äLowestÇ:-"+","-",OR
- -"*","/","^",AND,MOD
- -number,cellreference,variable,function
- call,NOT,"+","-"(unaryoperator)
- äHighestÇ:-Parenthesis
- üConstantsÇ:PIä(0.31415926535897932e+01)Ç,TODAYä(Juliandays
- whenyoupressTODAY,similartothefunction
- @TODAYonVIPprofessional.InLotus123,
- @TODAYwillberecalculatewhenyouloadthe
- file,butVIPwon't)
- Ç
- êRecalculationÇ:
- äRecalculationorders:Ç
- üNaturalÇ:Recalculateeachcellintheordertheyare
- inserted.Itworkslikefirst-come-first-
- serve.
- üRow:ÇRecalculateeachrowintheascendingorder.
- üColumn:ÇRecalculateeachcolumnintheascending
- order.
- äManualrecalculation:Ç
- Thespreadsheetstopsautomaticrecalculation.User
- hastopress<ALT-N>,<ALT-R>or<ALT-C>fornatural,
- roworcolumnrecalculation,where<ALT-N>meanspress
- <Alternate>keywithcharacterkey<N>simultaneously.
- äNotes:Ç
- Rowandcolumnrecalculationmethodsarefaster
- thannaturalrecalculationmethod.ThatisduetoSparse
- Matrix.Eachcellislinkedwithwithitsleft,right,
- top,downcellstightly.Fornaturalrecalculation,each
- cellhastolocateindividually.Forrowandcolumn
- recalculation,eachcellcanmovetoitsnextcellby
- usingthelinkedpointer.
-
-
- êFileformatÇ:
- äHeaderÇ:
- -2bytesforversionnumber,currentversionis1.0
- -268bytesforprint-dialoginformation(actually,
- only262bytesareused.Whenthegraphicpartis
- done,thisareawillbeusedforgraphinformation)
- -40bytesforwindowtitle.(39characterswitha
- nullcharacter)
- -2bytesforchecksumofthewindowtitletomake
- sureIamhandlingtherightworksheet.
- -256bytesforwidthofeachcolumns(youcannot
- displaycolumn0,butitisplannedtobeusedby
- theBASICinterpreterforinternaloperation).
- -2bytesforwindowtype(Itisuseless)
- -8bytesforcurrentwindowsize
- -4bytesfordisplayrangetoprow,topcolumn
- -4bytesforcurrentcellcursoraddress
- -2bytesforcurrentrecalculationmode
- äCellcontents:Ç
- -4bytesforcellrow,column
- -2bytesfordisplayattribute
- -2bytesfordecimalplace
- -2bytesfortokenslength
- -8bytesforcalculatedresult
- -tokenslengthbytesofactualtokens
-
-
- êPrintÇ:
- Youcanprintyourworksheettoafileortoprinter.
- Theprintroutinewillprintthose
- columnsthatfitsonthemargins.Ifsomecolumnsonthe
- printrangearenotprintonthefirstpass,theywillbe
- printedonlaterpasses.
-
-
- êConclusionÇ:
- Whatisnext?IplantoimplementtheCOPY,MOVEand
- ERASEcommandsonnextrelease.Somenewfunctionslike
- COLUMNandMATRIXshouldbedonealso.Whatarethey?Here
- are2examples:
- (äe.g.ÇIfyouhave"Quantity"incolumnBstarting
- fromrow1torow20,andyouhave"Price"on
- columnConthesamerowrange,andifyou
- wanttocalculatesubtotalforeachitem(each
- row),inLotus,youwilldothis:
- +b1*c1oncellD1
- copyd1startingfromd2downtod20
-
- ButifIfinishtheCOLUMNfunction,youcan
- dothisinonelineoncellD1:
- COLUMN(d1..d20,b1..b20*c1..c20)
- WhatdowegainbyusingCOLUMNfunctioninsteadof
- COPY?Speed!ByusingCOPYcommand,youhaveto
- recalculateasmanycellsasyoucopyto.Butusing
- COLUMNfunction,onlyoneformulawillbe
- recalculatedinaloop.Itshouldincreasethe
- recalculationperformance.
-
- äe.g.ÇMATRIX(a1..b3,a1..b3+d1..e3-3*(f1..g3))
- Well,itworkssimilartoCOLUMNfunctionandnot
- onlymatrixaddition,subtraction,butalsomatrix
- multiplicationandinversewillbefunctioning.If
- Ifinishthosefunctions,thenlinearregression
- andsimultaneousequationscanbesolvedeasily.
- )
-
- Well,thisprogramisnotfinishedyetanditneedsyour
- help(commentsandsuggestions)andsupport(êdonationÇ$10).
- Myaddressesare:
-
- Mr.Chor-mingLung
- 33GardenSt#3
- Boston,MA02114
- U.S.A.
-
- GEnie:LUNG
- CompuServe:72740,40
-
- IwilllogonGEniemoreoftenthanCompuServe.
-
- üP.S.Ç Iamplanningtowriteasimplifiedversionfordesk
- accesory.Anyonewhodonateswillreceiveitwhenitis
- done.Ablankdiskwithnameandaddressonlabelis
- necessaryforthedeskaccessoryprogram.
-
-